var top;
$(function () {
   top = new Vue({
       el:'#topController',
       data:{
           searchData:{
               type:1,   //默认艺术品
               keyword:''   //搜索关键词
           },
           isLogin:_token?true:false,
           currentPage:!_currentPage?'index':_currentPage,
           level:_level,
           nickName:_nickName,
           headImg:_headImg,
           userInfo:{}
       },
       methods:{
           loadTopData:function () {
               var that = this;
             sy.post('/web/login/findById',{},function (data) {
                 if(data.code == 0){
                     data = data.data;
                     if (data.nickName){
                         that.nickName = data.nickName;
                     }

                     if (data.headImg){
                         that.headImg = data.headImg;
                     }

                     if (data.userState == 1 && data.isVerify == 1){
                         that.headImg = data.artImg;
                         that.nickName = data.userName;
                     }

                     that.userInfo = data;
                 }
             })
           },
           setType:function (type) {
               this.searchData.type = type;
           },
           search:function () {
               if (this.searchData.type == 1){
                    location.href = sy.path+'/web/art?keyword='+encodeURI(this.searchData.keyword);
               }else {
                   location.href = sy.path+'/web/artist?keyword='+encodeURI(this.searchData.keyword);
               }
           },
           logout:function () {
               location.href = sy.path+'/web/logout?back_url='+encodeURI(location.href);
           }
       },
       created:function () {
         this.loadTopData();
       },
       mounted:function () {
           sy.loadScript('static/web/js/art.js')
       }
   });
});